#include "Comm.hpp"
//#include "Log.hpp"
#include <cstdio>

int main()
{
    int fd=Open(FIFO_FILE,WRITER);
    if(fd<0)
    {
        Log()<<"Open: "<<strerror(errno)<<endl;
        return 2;
    }
    uint32_t b = 666;
    write(fd, &b, sizeof(b));
    // key_t key = CreatKey();
    // Log() << "key: " << key << "\n";
    // Log() << "create share memory begin\n";

    // int shmid = shmget(key, MEM_SIZE, IPC_CREAT);
    // if (shmid < 0)
    // {
    //     Log() << "shmget: " << strerror(errno) << endl;
    //     return 2;
    // }
    // Log() << "create shm success, shmid: " << shmid << "\n";
    // char *str = (char *)shmat(shmid, nullptr, 0);
    // Log() << "attach shm : " << shmid << " success\n";
    // while (true)
    // {
    //     printf("请输入# ");
    //     fflush(stdout);
    //     ssize_t s = read(0, str, MEM_SIZE);
    //     if (s > 0)
    //     {
    //         str[s] = '\0';
    //     }
    //     //Signal(fd);
    // }

    // shmdt(str);
    // Log() << "detach shm : " << shmid << " success\n";
    Close(fd, FIFO_FILE);
    return 0;
}
